package com.jyw.business.obstacles.controller;

import com.jyw.business.obstacles.domain.dto.web.ObsStatisticsBaseQueryDto;
import com.jyw.business.obstacles.domain.vo.web.CommonFaultsCountVO;
import com.jyw.business.obstacles.domain.vo.web.OrderFaultTypeStatisticsVO;
import com.jyw.business.obstacles.domain.vo.web.OrderStatisticsVO;
import com.jyw.business.obstacles.domain.vo.web.ServiceDeskStatisticsVO;
import com.jyw.business.obstacles.service.IObsOrderFaultService;
import com.jyw.common.core.controller.BaseController;
import com.jyw.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 最新统计接口
 *
 * @author 伍绍宇
 * @date 2021/07/19
 */
@Api(tags = "统计分析接口")
@RestController
@RequestMapping("/bus/statistics")
public class ObsOrderAmountController extends BaseController {


    @Autowired
    private IObsOrderFaultService iObsOrderFaultService;

    @PostMapping("/source")
    @ApiOperation("来源分析统计")
    public TableDataInfo<OrderStatisticsVO> statisticsSource(@RequestBody @Validated ObsStatisticsBaseQueryDto dto) {
        List<OrderStatisticsVO> list = iObsOrderFaultService.statisticsSource(dto);
        return getDataTable(list);
    }

    @PostMapping("/faultType")
    @ApiOperation("故障分类统计")
    public TableDataInfo<OrderFaultTypeStatisticsVO> statisticsFaultType(@RequestBody @Validated ObsStatisticsBaseQueryDto dto) {
        List<OrderFaultTypeStatisticsVO> list = iObsOrderFaultService.statisticsFaultType(dto);
        return getDataTable(list);
    }

    @PostMapping("/deptRepair")
    @ApiOperation("科室报修情况(工单数量)")
    public TableDataInfo<List<OrderStatisticsVO>> statisticsDeptRepair(@RequestBody @Validated ObsStatisticsBaseQueryDto dto) {
        List<OrderStatisticsVO> list = iObsOrderFaultService.statisticsDeptRepair(dto);
        return getDataTable(list);
    }

    @PostMapping("/engineer")
    @ApiOperation("工程师排名(工单数量)")
    public TableDataInfo<OrderStatisticsVO> statisticsEngineer(@RequestBody @Validated ObsStatisticsBaseQueryDto dto) {
        List<OrderStatisticsVO> list = iObsOrderFaultService.statisticsEngineer(dto);
        return getDataTable(list);
    }

    @PostMapping("/commonFault")
    @ApiOperation("常见故障统计")
    public TableDataInfo<List<CommonFaultsCountVO>> statisticsCommonFault(@RequestBody @Validated ObsStatisticsBaseQueryDto dto) {
        List<CommonFaultsCountVO> list = iObsOrderFaultService.statisticsCommonFault(dto);
        return getDataTable(list);
    }

    // TODO 服务台统计写不起走；有关联没有做，班次等
    @PostMapping("/work")
    @ApiOperation("服务台统计")
    public TableDataInfo<List<ServiceDeskStatisticsVO>> statisticsWork(@RequestBody @Validated ObsStatisticsBaseQueryDto dto) {
        List<ServiceDeskStatisticsVO> list = iObsOrderFaultService.statisticsWork(dto);
        return getDataTable(list);
    }

    @PostMapping("/exportSource")
    @ApiOperation("导出来源分析")
    public void exportSource(HttpServletResponse response, @Validated @RequestBody ObsStatisticsBaseQueryDto dto) {
        iObsOrderFaultService.exportSource(response, dto);
    }

    @PostMapping("/exportFaultType")
    @ApiOperation("导出故障分类")
    public void exportFaultType(HttpServletResponse response, @Validated @RequestBody ObsStatisticsBaseQueryDto dto) {
        iObsOrderFaultService.exportFaultType(response, dto);
    }

    @PostMapping("/exportDeptRepair")
    @ApiOperation("导出科室报修情况(工单数量)")
    public void exportDeptRepair(HttpServletResponse response, @Validated @RequestBody ObsStatisticsBaseQueryDto dto) {
        iObsOrderFaultService.exportDeptRepair(response, dto);
    }

    @PostMapping("/exportEngineer")
    @ApiOperation("导出工程师排名(工单数量)")
    public void exportEngineer(HttpServletResponse response, @Validated @RequestBody ObsStatisticsBaseQueryDto dto) {
        iObsOrderFaultService.exportEngineer(response, dto);
    }


}
